<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <div th:replace="~{fragments/header :: header(title='个人主页')}"></div>
</head>
<body>

<!-- 个人主页内容 -->
<div class="container mt-4">
    <div class="row">
        <!-- 侧边栏菜单 -->
        <div class="col-md-3">
            <div class="card">
                <div class="card-body">
                    <h5 class="card-title" th:text="${session.username}"></h5>
                    <ul class="list-group list-group-flush">
                        <li class="list-group-item">
                            <!-- 隐藏的表单 -->
                            <form id="orderForm" action="/order/all" method="get" style="display: none;">
                            </form>
                            <!-- 触发表单提交的链接 -->
                            <a href="#" class="text-decoration-none" onclick="submitOrderForm()">我的订单</a>
                        </li>
<!--                        <li class="list-group-item">-->
<!--                            <a th:href="@{/cart}" class="text-decoration-none">购物车</a>-->
<!--                        </li>-->
                        <li class="list-group-item">
                            <a href="#" class="text-decoration-none">我的钱包</a>
                        </li>
                        <li class="list-group-item">
                            <a href="#" class="text-decoration-none">我的地址</a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>

        <!-- 主内容区域 -->
        <div class="col-md-9">
            <div class="card">
                <div class="card-body">
                    <h4 class="card-title">欢迎回来，<span th:text="${session.username}">王小明！</span></h4>
                    <p class="card-text">这里是您的个人主页，您可以查看订单、管理购物车、钱包和地址。</p>

<!--                    &lt;!&ndash; 最近订单 &ndash;&gt;-->
<!--                    <div class="mt-4">-->
<!--                        <h5>最近订单</h5>-->
<!--                        <div class="list-group">-->
<!--                            <a th:href="@{/order/1}" class="list-group-item list-group-item-action">-->
<!--                                <div class="d-flex w-100 justify-content-between">-->
<!--                                    <h6 class="mb-1">订单 #1001</h6>-->
<!--                                    <small>2023-10-01</small>-->
<!--                                </div>-->
<!--                                <p class="mb-1">总金额：¥120.00</p>-->
<!--                                <small>状态：已完成</small>-->
<!--                            </a>-->
<!--                            <a th:href="@{/order/2}" class="list-group-item list-group-item-action">-->
<!--                                <div class="d-flex w-100 justify-content-between">-->
<!--                                    <h6 class="mb-1">订单 #1002</h6>-->
<!--                                    <small>2023-10-05</small>-->
<!--                                </div>-->
<!--                                <p class="mb-1">总金额：¥80.00</p>-->
<!--                                <small>状态：配送中</small>-->
<!--                            </a>-->
<!--                        </div>-->
<!--                    </div>-->

                    <!-- 钱包余额 -->
                    <div class="mt-4">
                        <h5>我的钱包</h5>
                        <div class="card">
                            <div class="card-body">
                                <h6 class="card-subtitle mb-2 text-muted">当前余额</h6>
                                <h4 class="card-title">¥ <span th:text="${user.balance}">500.00</span></h4>
                                <a href="#" class="card-link">充值</a>
                                <a href="#" class="card-link">交易记录</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 页脚 -->
<footer class="bg-light mt-5 py-4">
    <div class="container text-center">
        <p class="text-muted mb-0">© 2025 点餐系统 · 保留所有权利</p>
    </div>
</footer>

<!-- 脚本 -->
<script src="https://cdn.bootcdn.net/ajax/libs/bootstrap/5.1.3/js/bootstrap.bundle.min.js"></script>

<script>
    function submitOrderForm() {
        // 阻止默认的链接行为
        event.preventDefault();

        // 提交表单
        document.getElementById('orderForm').submit();
    }
</script>
</body>
</html>